package models

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Mobile   string `gorm:"type:char(11)"`
	Password string `gorm:"type:varchar(32)"`
	Address  string `gorm:"type:varchar(300)"`
	RealName string `gorm:"type:varchar(30)"`
}

func (u *User) UserLogin(db *gorm.DB, mobile string) error {
	return db.Debug().Where("mobile=?", mobile).First(u).Error

}

func (u *User) FindUserByMobile(db *gorm.DB, mobile string) error {
	return db.Debug().Where("mobile=?", mobile).Find(u).Error
}

func (u *User) UserDetail(db *gorm.DB, id int64) error {
	return db.Debug().Where("id=?", id).Find(u).Error
}

func (u *User) UserUpdates(db *gorm.DB, mobile string) error {
	return db.Debug().Where("mobile=?", mobile).Updates(u).Error
}
